package com.hxzy.mapper;

import com.hxzy.controller.login.req.LoginReq;
import com.hxzy.controller.user.req.UserReq;
import com.hxzy.controller.user.resp.UserResp;
import com.hxzy.entity.UserinfoWy;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserinfoWyMapper {
    int deleteByPrimaryKey(Long id);

    int insert(UserinfoWy record);

    int insertSelective(UserinfoWy record);

    UserinfoWy selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(UserinfoWy record);

    int updateByPrimaryKey(UserinfoWy record);

    /**
     * 根据账号查询个数
     * @param account
     * @return
     */
    @Select(value = "select count(0) from USERINFO_WY where NAME=#{account}")
    long selectByNameCount(String account);

    /**
     * 根据参数查询 数据库
     * @param req
     * @return
     */
    UserinfoWy searchByCondition(@Param(value = "req") LoginReq req);

    /**
     * 根据令牌查询
     * @param uuid
     * @return
     */
    UserinfoWy searchByToken(String uuid);

    @Update(value = "update USERINFO_WY set TOKEN=NULL,TOKEN_Expired=NULL WHERE TOKEN=#{token}")
    int  logout(String token);

    /**
     * 分页查询
     * @param req
     * @return
     */
    List<UserResp> searchPage(@Param(value = "req") UserReq req);

    /**
     * 新增验证数据有效性
     * @param mobile
     * @return
     */
    @Select(value = "select count(0) from USERINFO_WY where MOBILE=#{mobile}")
    int existsMobile(String mobile);

    /**
     * 批量更新值
     * @param ids
     * @param status
     * @return
     */
    int updateBatchStatus(@Param(value = "ids") Long[] ids, @Param(value = "status") String status);
}